﻿@model IEnumerable<MvcPrinciples.Models.Person>

@{
    ViewBag.Title = "List of persons";
    Layout = "~/Views/_CommonLayout.cshtml";
}

<div>
	<h2>Here is the list of all persons</h2>
	<div>
		@foreach (var item in Model)
		{
			<div class="form-control" style="height: 100px">
				<div>
					<div style="width: 30%; float: left">
						@string.Format("Name: {0}", item.Name)
					</div>
					<div style="width: 20%; float: right">
						@string.Format("Age: {0}", item.Age)
					</div>
					<div style="width: 20%; float: right;">
						@string.Format("Date of Birth: {0}", item.BirthDate.ToShortDateString())
					</div>
					<div style="width: 30%; float: right;">
						@if (item.Image.Key != Guid.Empty)
						{
							<img src="@Url.Action("GetImage", new {id = item.Image.Key, type = item.Image.Value})" style="max-height: 80px; max-width: 100px" alt="Image" />
						}
					</div>
				</div>
				<br /> @Html.ActionLink("Add or view rewards", "Index", "PersonReward", new { id = item.Id }, null)
				<br /> @Html.ActionLink("Edit this person", "EditPerson", "Person", new { id = item.Id }, null)
			</div>
		}
	</div>
	<div>
		<input type="button" value="Add person" class="btn btn-success" onclick="location.href = '@Url.Action("AddPerson")'" />
		<input type="button" value="Get as list" class="btn btn-info" onclick="location.href = '@Url.Action("DownloadList")'" />
	</div>
</div>


